package com.mrwind.pgsql.orm.mapper;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("baseDaoImpl")
public class BaseDaoImpl implements IBaseDao{

	@Autowired
	SqlSessionTemplate sqlSession_pgsql;
	
	public <T> T qryOneByXML(String xmlSqlId, Object param) {
		return sqlSession_pgsql.selectOne(xmlSqlId, param);
	}

	public <T> List<T> qryEntityListByXML(String xmlSqlId, Object param) {
		return sqlSession_pgsql.selectList(xmlSqlId, param);
	}

	public List<Map<String, Object>> qryMapListByXML(String xmlSqlId,Object param) {
		return sqlSession_pgsql.selectList(xmlSqlId, param);
	}

	public List<Map<String, Object>> qryMapListBySql(String sql) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("sql", sql);
		return sqlSession_pgsql.selectList("com.mrwind.orm.mapper.BaseDaoMapper.qryMapListBySql",param);
	}
	
}
